<?php

require_once 'configs/Config.php';

//class for caching an object
class ObjectCache {
	
	protected $cache;
	
	public function getCache()	{
		return $this->cache;
	}
	
	public function __construct($cacheEntity, $cacheTime = 3600, $params = array(), $prefix = null, $backend = CacheConst::CACHE_BACKEND_APC, $backendOptions = array()) {
		$params ['caching'] = !CacheConfig::$cacheDisabled;
		$params ['cached_entity'] = $cacheEntity;
		$params ['lifetime'] = $cacheTime;
		$params ['cache_id_prefix'] = $prefix;
		
		//automatically serialize object
		if (! isset ( $params ['automatic_serialization'] ))
			$params ['automatic_serialization'] = true;
		$this->cache = Zend_Cache::factory ( CacheConst::CACHE_FRONTEND_CLASS, $backend, $params, $backendOptions );
	}
	
	//proxy design pattern
	public function __call($method, $params) {
		return call_user_func_array ( array ($this->cache, $method ), $params );
	}
}

?>